#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=230;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
char str1[maxn],str2[maxn];
LL dp[maxn][maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  cin>>(str1+1);
  cin>>(str2+1);
  LL len1=strlen(str1+1);LL len2=strlen(str2+1);
  for(LL i=1;i<=len1;i++){
    for(LL j=1;j<=len2;j++){
        if(str1[i]==str2[j]){
            dp[i][j]=dp[i-1][j-1]+1;
        }
        else{
            dp[i][j]=max(dp[i-1][j-1],max(dp[i-1][j],dp[i][j-1]));
        }
    }
  }
  cout<<dp[len1][len2]<<endl;
return 0;
}
